package com.mk.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class User implements Serializable, UserDetails {

    /**
     * 状态 0不在线 1在线
     */
    public static final Integer NOT_ONLINE = 0;
    public static final Integer ONLINE = 1;

    @Serial
    private static final long serialVersionUID = 1L;

    private Long id;

    //微信用户唯一标识
//    private String openid;

    //姓名
    private String username;

    //密码
    private String password;

    //手机号
    private String phone;

    //性别 0 女 1 男
    private String gender;

    //身份证号
    private String idNumber;

    //头像
    private String image;

    //状态（0不在线 1在线）
    private Integer status;

    //注册时间
    private LocalDateTime createTime;

    //上线时间
    private LocalDateTime onlineTime;

    //下线时间
    private LocalDateTime offlineTime;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return List.of();
    }

    @Override
    public boolean isAccountNonExpired() {
        return UserDetails.super.isAccountNonExpired();
    }

    @Override
    public boolean isAccountNonLocked() {
        return UserDetails.super.isAccountNonLocked();
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return UserDetails.super.isCredentialsNonExpired();
    }

    @Override
    public boolean isEnabled() {
        return UserDetails.super.isEnabled();
    }
}
